import Vue from 'vue'
import Vuex from 'vuex'
import state from './state'
import getters from './getters'
import mutations from './mutations'
import actions from './actions'

Vue.use(Vuex)
const asyncStorgage = (store)=>{
  store.subscribe((mutation,state)=>{
    // 存储到localstorage里面去
    window.localStorage.setItem('smart-userInfo',JSON.stringify(state.userInfo))
  })
}
export default new Vuex.Store({
  plugins: [asyncStorgage],
  state,
  getters,
  mutations,
  actions
})
